<?php
class Exts_Models_UsersRoles extends Exts_Db_Table_Abstract
{
    protected $_name = 'acl_users_roles';
    protected $_primary = array( 'user_id', 'role_id' );

    public function save( $userId, $roleId )
    {
        $row = $this->fetchRow(
            $this->select()
            ->where('user_id=?', $userId )
            ->where('role_id=?', $roleId )
        );

        if( count( $row )) {
            return false;
        }
        $row = $this->createRow();
        $row->user_id = $userId;
        $row->role_id = $roleId;
        $row->save();

    }
}
